package com.itheima.reggie.controller;

import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Dish;
import com.itheima.reggie.domain.Setmeal;
import com.itheima.reggie.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author fanYuLe
 * @Date 2023/3/8 18:13
 * @Blog blog.fanYuLe.net/996.mba
 * @Description:
 */
@RestController
public class SetmealController {
    @Autowired
    private SetmealService setmealService;
    //套餐列表
    @Cacheable(value = "setmeal",key = "#categoryId")
    @GetMapping("/setmeal/list")
    public ResultInfo list(Long categoryId,Integer status){
        List<Setmeal> list =setmealService.list(categoryId,status);
        return ResultInfo.success(list);
    }
    //套餐包含的菜品回显
    @GetMapping("/setmeal/dish/{setmealId}")
    public ResultInfo findDishBySetmealId(@PathVariable("setmealId") Long setmealId){
        List<Dish> dishList=setmealService.findDishBySetmealId(setmealId);
        return ResultInfo.success(dishList);
    }
}

